#include "WorldProcess.h"
#include "ScriptMgr.h"
#include "NGLog.h"
#include "GatewayOpcodes.h"
#include "GameUserCommand.h"
#include "ScriptWorldProcess.h"
#include "OpcodesEx.h"
#include "GameServerCommand.h"
#include "CenterBattleManager.h"
#include "CenterBattleLogManager.h"
#include "Character.h"
#include "url.h"
#include "json/json.h"
#include "nxweb/nxweb.h"
#include "MD5.h"
#include "PubDataManager.h"

#include "GameDefine.h"
#include LOGIC_MGR_PATH
#include "CenterMatchManager.h"
#include "GameDataEnum.h"

#define SECUREKEY "mef3mervzl1SykohhufmdkhvdbCpokkt"
#define GATEWAYKEY "9ecfe5152faac79d8a31e1902c015450"

String get_create_centerbattle_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 1:
		return "创建组局成功！";
	case 2:
		return "创建失败：创建牌桌达到上限！";
	case 3:
		return "创建失败：错误的局数！";
	case 4:
		return "创建失败：局数和时间重复！";
	case 5:
		return "创建失败：无效的局数！";
	case 6:
		return "创建失败：无效的时间！";
	case 7:
		return "创建失败：无效的游戏ID！";
	case 8:
		return "创建失败：创建数据失败！";
	case 13:
		return "创建失败：房卡不足！";
	case 15:
		return "创建失败：无效的游戏玩法！";
	case 100:
		return "创建失败：无效的玩家PID！";
	case 101:
		return "创建失败：创建组局参数不能为空！";
	case 102:
		return "创建失败：该PID玩家还未创建用户！";
	case 103:
		return "创建失败：该PID玩家没有银行数据！";
	case 104:
		return "创建失败：该PID玩家没有角色数据！";
	case 105:
		return "创建失败：未取得默认玩法配置，您需要登录APP，创建一次对应玩法的牌局后，方可使用机器人快捷快局！";
	case 106:
		return "创建失败：您已经在其他游戏中进行游戏了！";
	default:
		return "创建失败：创建组局失败！";
	}

	return "";
}

String get_querydata_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "查询失败：无效的房间号！";
	case 1:
		return "查询数据成功！";
	case 2:
		return "查询失败，未找到该房号的牌桌！";
	default:
		return "查询失败：查询数据失败！";
	}

	return "";
}

String get_normal_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "指令执行失败：指令执行失败！";
	case 1:
		return "指令执行成功：指令执行成功！";
	case 2:
		return "指令执行失败：错误的操作类型！";
	case 3:
		return "指令执行失败：错误的时间戳！";
	case 4:
		return "指令执行失败：错误的参数！";
	case 5:
		return "指令执行失败：错误的签名！";
	case 6:
		return "指令执行失败：错误的目标ID！";
	case 7:
		return "指令执行失败：空的邮件标题！";
	case 8:
		return "指令执行失败：空的邮件内容！";
	case 9:
		return "指令执行失败：错误的道具ID！";
	case 10:
		return "指令执行失败：错误的道具数量！";
	case 11:
		return "指令执行失败：错误的源对象PID！";
	case 12:
		return "指令执行失败：错误的目标对象PID！";
	case 13:
		return "指令执行失败：错误的道具模式ID！";
	case 14:
		return "指令执行失败：道具数量不能为0！";
	case 15:
		return "指令执行失败：源对象道具数量不足！";
	default:
		return "指令执行失败：指令执行失败！";
	}

	return "";
}

String get_queryefforts_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "查询失败：未知原因！";
	case 1:
		return "数据查询成功！";
	case 2:
		return "查询失败，玩家不存在！";
	case 3:
		return "查询失败：玩家没有成就！";
	default:
		return "查询失败：查询数据失败！";
	}

	return "";
}

String get_operatorgamecommonconfig_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "操作失败！";
	case 1:
		return "操作成功！";
	case 2:
		return "参数错误！";
	case 3:
		return "节点中缺少op_type或者agent_id！";
	case 4:
		return "未找到要操作的配置数据，对应agent_id下位查询到数据！";
	case 5:
		return "修改数据时，缺少data节点！";
	case 6:
		return "修改数据时，data节点中没有找到一个指定修改的数据节点，如model_id,max_count等";
	case 7:
		return "缺少index参数";
	case 8:
		return "缺少model_id之类的必要参数";
	case 9:
		return "新增的关键数据重复";
	case 10:
		return "已经存在同样的数据，无需增加";
	case 11:
		return "Json数据转换失败";
	case 12:
		return "未找到要操作的配置项";
	case 13:
		return "缺少type参数";
	case 14:
		return "配置的几率总和不是100%";
	default:
		return "未知错误，操作失败！返回结果大于6";
	}
	
	return "";
}

String get_sendmail_resultinfo(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "操作失败！";
	case 1:
		return "操作成功！";
	case 2:
		return "缺少必要参数pid或者title或者content";
	case 3:
		return "必要参数为空pid或者title或者content";
	case 4:
		return "参数Json转换失败";
	default:
		return "未知错误，操作失败！返回结果大于6";
	}
	
	return "";
}


String get_gateway_opitems_result(const uint8 & result)
{
	switch (result)
	{
	case 0:
		return "参数为空";
	case 1:
		return "操作成功！";
	case 2:
		return "缺少必要参数之一gz_id,pid,items,pay_order";
	case 3:
		return "未找到目标玩家";
	case 4:
		return "玩家没有那么多道具数量可以扣";
	case 5:
		return "json转换失败（数字，字符串？循环 非循环？）";
	default:
		return "未知错误，操作失败！返回结果大于6";
	}
	
	return "";
}

String get_all_resultinfo(const uint32 & func_type, const uint32 & result)
{
	switch(func_type)
	{
	case enGatewayFunctionType_QueryCenterBattle:			// 查询组局信息结果
		return get_querydata_resultinfo(result);
	case enGatewayFunctionType_CreateCenterBattle:			// 创建组局
		return get_create_centerbattle_resultinfo(result);
	case enGatewayFunctionType_QueryEfforts:				// 查询成就
		return get_queryefforts_resultinfo(result);
	case enGatewayFunctionType_OperatorCommonConfig:		// 操作公共配置	
		return get_operatorgamecommonconfig_resultinfo(result);
	case enGatewayFunctionType_SendMail:					// 网关发送邮件
		return get_sendmail_resultinfo(result);
	case enGatewayFunctionType_OperatorItems:				// 网关操作道具
		return get_gateway_opitems_result(result);
	default:
		return get_normal_resultinfo(result);
	}
}

static int  getway_http_handle(void * connection, void * request, void* respons)
{
	if (!connection || !request || !respons)
		return NXWEB_ERROR;

	nxweb_http_server_connection * conn = (nxweb_http_server_connection*)connection;
	nxweb_http_request * req = (nxweb_http_request*)request;
	nxweb_http_response * resp = (nxweb_http_response*)respons;	// 返回结果字符串

	String strOp;
	String strTs;
	String strParmars;
	String strSig;

	uint8 function_type = 0;
	if (req->parameters)
	{// 接收到的参数

		nx_simple_map_entry* itr;
		for (itr = nx_simple_map_itr_begin(req->parameters); itr; itr = nx_simple_map_itr_next(itr))
		{
			String key = itr->name;
			String value = itr->value;

			Log.Debug("getway_http_handle", "recv key[%s] value[%s]", key.c_str(), value.c_str());
			if (!key.compare("op"))
				strOp = value;

			if (!key.compare("ts"))
				strTs = value;

			// 参数接收下来需要进行decode操作
			if (!key.compare("params"))
				strParmars = value;

			if (!key.compare("sig"))
				strSig = value;
		}
	}

	// Log.Debug("getway_http_handle","op[%s] ts[%s] params[%s] sig[%s]", strOp.c_str(), strTs.c_str(), strParmars.c_str(), strSig.c_str());

	String extra_info;
	String share_info;
	uint32 result = 1; // 0 失败 1 成功 2 空op 3 空ts 4 空参数 5 空sig 6 无效的pid 7 空内容
	do
	{
		if (strOp == "")
		{
			result = 2;
			break;
		}

		if (strTs == "")
		{
			result = 3;
			break;
		}

		if (strParmars == "")
		{
			result = 4;
			break;
		}

		if (strSig == "")
		{
			result = 5;
			break;
		}

		String opModeStr = req->path_info;
		std::vector<String> vStr = StringUtil::split(opModeStr, "/");
		if (vStr.size())
			opModeStr = vStr[0];

		std::vector<String> vStrPar = StringUtil::split(opModeStr, "?");
		if (vStrPar.size())
			opModeStr = vStrPar[0];

		// 签名验证
		CMD5 md5;
		String serverSig = md5.GenerateMD5(strOp + strTs + strParmars + SECUREKEY);
		if(!opModeStr.compare("gateway_op_items"))
		{
			serverSig = md5.GenerateMD5(strOp + strTs + strParmars + GATEWAYKEY);
			Log.Debug("getway_http_handle", "combin par str[%s]", (strOp + strTs + strParmars + GATEWAYKEY).c_str());
		}
		
		String chuan = strOp + strTs + strParmars + SECUREKEY;
		String serverSig2 = md5.GenerateMD5(strParmars);
		Log.Debug("getway_http_handle", "strOp[%s] strTs[%s] strParmars[%s] serverSig[%s] strSig[%s]", strOp.c_str(), strTs.c_str(), strParmars.c_str(), serverSig.c_str(), strSig.c_str());
		Log.Error("getway_http_handle", "serverSig2[%s] chuan[%s] opModeStr[%s]", serverSig2.c_str(), chuan.c_str(), opModeStr.c_str());
		result = !serverSig.compare(strSig);
		if (result == 1)
		{
			// 优先处理配置修改相关
			result = sGameCommonConfigMgr.GatewayOperatorCommonConfig(opModeStr, strParmars, extra_info);
			function_type = enGatewayFunctionType_OperatorCommonConfig;
			
			if (!opModeStr.compare("send_mail"))
			{// 发送系统邮件
				result = sGLMgr.SendSystemMail(strParmars);
				function_type = enGatewayFunctionType_SendMail;
			}
			else if(!opModeStr.compare("gateway_send_mail"))
			{// 网关发送邮件给玩家New
				result = sGLMgr.SendSystemMailNew(strParmars);
				function_type = enGatewayFunctionType_SendMail;
			}
			else if (!opModeStr.compare("send_items"))
			{// 赠送钻石
				result = sGLMgr.PlayerGiveItemsFromGWToPlayer(strParmars);
				function_type = enGatewayFunctionType_SendDiamand;
			}
			else if (!opModeStr.compare("get_item_num"))
			{// 查询道具数量
				result = sGLMgr.QueryPlayerItemNumber(strParmars, extra_info);
				function_type = enGatewayFunctionType_QueryItem;
			}
			else if (!opModeStr.compare("create_game_channel"))
			{// 创建棋牌圈战场
				result = sCenterBattleMgr.RobotCreateGameChannel(strParmars);
				function_type = enGatewayFunctionType_CreateGameChannel;
			}
			else if (!opModeStr.compare("systemcreate_game_channel"))
			{// 系统创建组局
				result = sCenterBattleMgr.CreateCenterBattleBySystem(strParmars);
				function_type = enGatewayFunctionType_CreateGameChannel;
				Log.Debug("getway_http_handle", "systemcreate_game_channel");
			}
			else if (!opModeStr.compare("create_center_battle"))
			{// 创建组局
				result = sCenterBattleMgr.RobotCreateCenterBattle(strParmars, extra_info, share_info);
				function_type = enGatewayFunctionType_CreateCenterBattle;
			}
			else if (!opModeStr.compare("query_centerbattle_record"))
			{// 查询组局信息结果
				result = sCenterBattleLogMgr.QueryCenterBattleLog(strParmars, extra_info, share_info);
				function_type = enGatewayFunctionType_QueryCenterBattle;
			}
			else if (!opModeStr.compare("exit_game_server"))
			{// 退出当前游戏服务器
				result = sGLMgr.ExitGameServer(strParmars);
				function_type = enGatewayFunctionType_ExitGameServer;
			}
			else if (!opModeStr.compare("operate_center_battle"))
			{// 组局操作
				result = sGLMgr.DealOperateCenterBattleGateway(strParmars);
				function_type = enGatewayFunctionType_OperateCenterBattle;
			}
			else if (!opModeStr.compare("add_items"))
			{// 添加道具数量
				result = sGLMgr.AddItemFromGatewayToPlayer(strParmars);
				function_type = enGatewayFunctionType_AddItems;
			}
			else if (!opModeStr.compare("operator_items"))
			{// 添加道具数量
				result = sGLMgr.OperatorItemFromGatewayToPlayer(strParmars);
				function_type = enGatewayFunctionType_AddItems;
			}
			else if (!opModeStr.compare("query_efforts"))
			{// 查询成就
				result = sGLMgr.QueryPlayerEffortsFromGateway(strParmars, extra_info);
				function_type = enGatewayFunctionType_QueryEfforts;
			}
			else if (!opModeStr.compare("get_effort_bounty"))
			{// 领取成就奖励
				result = sGLMgr.GetEffortBountyFromGateway(strParmars, extra_info);
				function_type = enGatewayFunctionType_GetEffortBounty;
			}
			else if (!opModeStr.compare("query_town_player"))
			{// 获取房间人数
				sGLMgr.GetRoomPlayerCountByGzid(strParmars, extra_info);
				function_type = enGatewayFunctionType_QueryRoomPlayerCount;
			}
			else if (!opModeStr.compare("query_item_num"))
			{
				sGLMgr.GetItemNumByGzid(strParmars, extra_info);
				function_type = enGatewayFunctionType_QueryItemNumCount;
			}
			else if (!opModeStr.compare("query_online_playercount"))
			{// 查询在线玩家数量
				sGLMgr.QueryOnlinePlayerCount(strParmars, extra_info);
				function_type = enGatewayFunctionType_QueryOnlineCount;
			}
			else if (!opModeStr.compare("operate_effort"))
			{// 操作成就
				uint32 nOp = StringConverter::parseUnsignedInt(strOp);
				switch (nOp)
				{
				case 1:
				{// 增加成就计数
					result = sGLMgr.AddEffortFinishCountByGateway(strParmars, extra_info);
					function_type = enGatewayFunctionType_OperateEffort;
				}
				break;
				case 2:
				{// 判断成就达到计数
					result = sGLMgr.HasEffortCompalateAtValueByGateway(strParmars, extra_info);
					function_type = enGatewayFunctionType_OperateEffort;
				}
				break;
				case 3:
				{// 设置成就计数
					result = sGLMgr.SetEffortCompalateAtValueByGateway(strParmars, extra_info);
					function_type = enGatewayFunctionType_OperateEffort;
				}
				break;
				default:
					break;
				}
			}
			else if (!opModeStr.compare("query_channel_list"))
			{// 查询牌桌列表信息，设置牌桌信息，入座等
				result = sGLMgr.GetGameTableListSelf(strParmars, extra_info);
			}
			else if (!opModeStr.compare("userbuy_items"))
			{// 购买道具
				Json::Value valParmars;
				Json::Reader reader;
				reader.parse(strParmars, valParmars);

				result = sGLMgr.UserBuyItems(valParmars, extra_info) > 0 ? 1 : 0;
				function_type = enGatewayFunctionType_UserBuyItems;
			}
			else if (!opModeStr.compare("club_battle_timesup"))
			{// 通知俱乐部牌局超时结束
				result = sGLMgr.NoticeClubBattleTimesUp(strParmars);
				function_type = enGatewayFunctionType_NoticeClubBattleTimeup;
			}
			else if (!opModeStr.compare("send_system_message"))
			{// 发送系统消息
				result = sGLMgr.SendSystemMessageFromGateway(strParmars);
				function_type = enGatewayFunctionType_SendSystemMessage;
			}
			else if(!opModeStr.compare("change_order_data"))
			{// 改变排行数据
				result = sGLMgr.ChangeCharacterOrderData(strParmars);
				function_type = enGatewayFunctionType_ChangeOrderData;
			}
			else if(!opModeStr.compare("get_match_watchchannel"))
			{// 获取可观战牌桌
				result = sGLMgr.GetMatchWatchChannelId(strParmars, extra_info);
				function_type = enGatewayFunctionType_MatchWatchChannel;
			}
			else if(!opModeStr.compare("club_manager_tuifen"))
			{// 俱乐部管理员退分
				result = sGLMgr.PlayerClubTuiFenWhenPlayingComplate(strParmars);
				function_type = enGatewayFunctionType_MatchWatchChannel;
			}
			else if(!opModeStr.compare("player_notice_clubtuifen"))
			{// 玩家通知俱乐部退分
				result = sGLMgr.HallDealPlayerClubTuifen(strParmars);
				function_type = enGatewayFunctionType_MatchWatchChannel;
			}
			else if(!opModeStr.compare("gateway_op_items"))
			{// 网关购买商品
				result = sGLMgr.GatewayOpeartorGoods(strParmars, extra_info);
				function_type = enGatewayFunctionType_OperatorItems;
			}
			else if (!opModeStr.compare("create_game_match"))
			{
#ifdef CENTERMATCH
				result = sCenterMatchMgr.CreateGameMatch(strParmars);
				function_type = enGatewayFunctionType_CreateGameMatch;
#endif // !


			}
			else if (!opModeStr.compare("notify_match_start"))
			{
#ifdef CENTERMATCH
				result = sCenterMatchMgr.StartGameMatch(strParmars);
				function_type = enGatewayFunctionType_NoticeMatchStart;
#endif // !
			}
			else if (!opModeStr.compare("notify_match_Dissolve"))
			{
#ifdef CENTERMATCH
				result = sCenterMatchMgr.GameMatchDissolve(strParmars);
				function_type = enGatewayFunctionType_MatchDissolve;
#endif // !
			}
			else if (!opModeStr.compare("notify_match_create_char"))
			{
#ifdef CENTERMATCH
				result = sCenterMatchMgr.GameMatchCreatePlayer(strParmars);
				function_type = enGatewayFunctionType_MatchCreateChar;
#endif // !
			}
			else if (!opModeStr.compare("notify_center_create_match"))
			{
#ifdef CENTERMATCH
				CharPtr pChr;
				result = sCenterMatchMgr.CreateCenterMatch(pChr, strParmars);
				function_type = enGatewayFunctionType_CenterCreateMatch;

#endif // !
			}
			else if (!opModeStr.compare("notify_center_reset_match")) 
			{
#ifdef CENTERMATCH
				result = sCenterMatchMgr.ReSetCenterMatch(strParmars);
				function_type = enGatewayFunctionType_CenterResetMatch;
#endif // !
			}
			else if (!opModeStr.compare("notify_center_close_match"))
			{
#ifdef CENTERMATCH
				uint32 cm_id = 0;
				Json::Value json_object;
				Json::Reader  reader;
				reader.parse(strParmars, json_object);
				if (json_object.isMember("cm_id"))
					cm_id = json_object["cm_id"].asUInt();
				CenterMatch cm;
				sCenterMatchMgr.GetCenterMatch(cm_id, &cm);

				uint8 mresult = 1;
				if (cm.cm_id == 0)
				{
					mresult = 2;
				}
				if (cm.match_status != enMatchStatus_SignUp)
				{
					mresult = 3;
				}
				if (cm.status == 255)
				{
					mresult = 4;
				}
				if (mresult == 1)
				{
					sCenterMatchMgr.CenterMatchOver(cm.cm_id, enCenterMatchOverType_FZKillMatch);
					result = 1;
				}
				else
					result = 0;
				function_type = enGatewayFunctionType_CenterCloseMatch;
#endif // !
			}
		}

	} while (0);
	
	// 返还结果
	Json::Value val, valExtra, valShare;
	val["status"] = result;
	
	Json::Reader reader;
	reader.parse(extra_info, valExtra);
	reader.parse(share_info, valShare);
	
	if (valExtra.size())
		val["data"] = valExtra;
	if (valShare.size())
		val["desc"] = valShare;

	// 通过配置来读取原因
	val["msg"] = get_all_resultinfo(function_type, result);
	
	Json::FastWriter w;
	String strResult = w.write(val);
	nxweb_response_append_str(resp, strResult.c_str());

	// 解析处理函数参数
	Log.Debug("getway_http_handle", " strResult[%s]", strResult.c_str());
	return NXWEB_OK;
}

//-----------------------------------------------------------------------
void  register_world_process(ScriptMgr * mgr)
{
	/////////////////////////////// 公共协议注册 /////////////////////////////
	mgr->register_server_process(SMSG_TGW_HEADER, script_world_process_system);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", SMSG_TGW_HEADER, "script_world_process_system");

	// 聊天协议
	mgr->register_server_process(CMSG_CHATDATA, script_world_process_chat);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHATDATA, "script_world_process_chat");
	// 新喇叭聊天协议
	mgr->register_server_process(CMSG_SINGLE_LABA_CHAT, script_world_process_single_labachat);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SINGLE_LABA_CHAT, "script_world_process_single_labachat");
	// 兑换背包
	mgr->register_server_process(CMSG_EXCHANGEBAG, script_world_process_exchangebag);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_EXCHANGEBAG, "script_world_process_exchangebag");
	// 打开背包
	mgr->register_server_process(CMSG_OPENBACKPACK, script_world_process_openbackpack);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_OPENBACKPACK, "script_world_process_openbackpack");
	// 用户领取操作
	mgr->register_server_process(CMSG_GETBONUS_OPERATOR, script_world_process_basegaingift);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETBONUS_OPERATOR, "script_world_process_basegaingift");
	// 数据中转公共协议
	mgr->register_server_process(CMSG_GAME_ORDER, script_world_process_transfer);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GAME_ORDER, "script_world_process_transfer");
	// 请求连接/断开游戏服
	mgr->register_server_process(CMSG_LINKGAMESERVER, script_world_process_operationgameserver);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_LINKGAMESERVER, "script_world_process_operationgameserver");
	// 请求退出游戏(把资产数据拷贝到银行)
	mgr->register_server_process(SMSG_EXITGAMESERVER, script_world_process_exitgameserver);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", SMSG_EXITGAMESERVER, "script_world_process_exitgameserver");
	// 请求退出游戏(把资产数据拷贝到银行)
	mgr->register_server_process(SMSG_EXITGAMESERVEREX, script_world_process_exitgameserverex);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", SMSG_EXITGAMESERVEREX, "script_world_process_exitgameserverex");
	// 切换服务器请求
	mgr->register_server_process(CMSG_CHANGELINK_REQUEST, script_world_process_request_changeserver);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHANGELINK_REQUEST, "script_world_process_request_changeserver");
	// 切换服务器请求
	mgr->register_server_process(CMSG_SECOND_LOGINSERVER, script_world_process_second_authentication);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SECOND_LOGINSERVER, "script_world_process_second_authentication");
	// 修改socketip
	mgr->register_server_process(CMSG_SETFAKEIP, script_world_process_changesocketip);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SETFAKEIP, "script_world_process_changesocketip");
	// 验证版本信息
	mgr->register_server_process(CMSG_CHECKVISION, script_world_process_checkversion);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHECKVISION, "script_world_process_checkversion");
	// 获取终端信息
	mgr->register_server_process(CMSG_MOBILEINFO, script_world_process_getterminalinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_MOBILEINFO, "script_world_process_getterminalinfo");
	// 获取银行历史操作
	mgr->register_server_process(CMSG_GETBANKHISTORY, script_world_process_getbankhistory);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETBANKHISTORY, "script_world_process_getbankhistory");
	// 领取在线奖励
	mgr->register_server_process(CMSG_GETONLINE_BONUS, script_world_process_getonlinegift);
	Log.Debug("World Process", "Register opcode 0x%04x Process:[%s]", CMSG_GETONLINE_BONUS, "script_world_process_getonlinegift");
	// 获取商城商品列表
	mgr->register_server_process(CMSG_GETSHOPGOODSLIST, script_world_process_getgoodslist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETSHOPGOODSLIST, "script_world_process_getgoodslist");
	// 购买商品
	mgr->register_server_process(CMSG_BUYGOODS, script_world_process_buygoods);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_BUYGOODS, "script_world_process_buygoods");
	// 保存系统设置
	mgr->register_server_process(CMSG_SAVESYSTEMSET, script_world_process_savesystemsetpack);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SAVESYSTEMSET, "script_world_process_savesystemsetpack");
	// 保存公共系统设置
	mgr->register_server_process(CMSG_SAVECOMMONSET, script_world_process_savecommonsetpack);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SAVECOMMONSET, "script_world_process_savecommonsetpack");
	// 获取效果
	mgr->register_server_process(CMSG_GETEFFECTS, script_world_process_geteffects);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETEFFECTS, "script_world_process_geteffects");
	// 获取邮件列表
	mgr->register_server_process(CMSG_GETMAILSLIST, script_world_process_getmailslist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETMAILSLIST, "script_world_process_getmailslist");
	// 操作邮件
	mgr->register_server_process(CMSG_OPERATORMAIL, script_world_process_operatormail);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_OPERATORMAIL, "script_world_process_operatormail");
	// 修改二级密码
	mgr->register_server_process(CMSG_CHANGESECONDPWD, script_world_process_changesecondpwd);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHANGESECONDPWD, "script_world_process_changesecondpwd");
	// 验证二级密码
	mgr->register_server_process(CMSG_VALIDATESECONDPWD, script_world_process_validatesecondpwd);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_VALIDATESECONDPWD, "script_world_process_validatesecondpwd");
	// 兑换兑换卡
	mgr->register_server_process(CMSG_EXCHANGETICKET, script_world_process_exchangeticket);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_EXCHANGETICKET, "script_world_process_exchangeticket");
	// SMSG_EXCHANGEGATEWAYGOODS = 0x005B,	兑换网关配置道具 
	mgr->register_server_process(SMSG_EXCHANGEGATEWAYGOODS, script_world_process_exchangegatewaygoods);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", SMSG_EXCHANGEGATEWAYGOODS, "script_world_process_exchangegatewaygoods");
	// 更改昵称
	mgr->register_server_process(CMSG_RENAME, script_world_process_rename);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_RENAME, "script_world_process_rename");
	// 更改QQ黄钻等级
	mgr->register_server_process(CMSG_QQDIAMONDLEVEL, script_world_process_baseupdatebiamondlevel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_QQDIAMONDLEVEL, "script_world_process_baseupdatebiamondlevel");
	// 黄钻图标状态
	mgr->register_server_process(CMSG_QQDIAMONDOPERATION, script_world_process_baseoperationbiamondlevel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_QQDIAMONDOPERATION, "script_world_process_baseoperationbiamondlevel");
	// 获取银行存款信息
	mgr->register_server_process(CMSG_GETBANKCOINS, script_world_process_getbankcoins);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETBANKCOINS, "script_world_process_getbankcoins");
	// 存款
	mgr->register_server_process(CMSG_PUTCOINSINBANK, script_world_process_putcoinsinbank);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_PUTCOINSINBANK, "script_world_process_putcoinsinbank");
	// 取款
	mgr->register_server_process(CMSG_GETCOINSFROMBANK, script_world_process_getcoinsfrombank);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETCOINSFROMBANK, "script_world_process_getcoinsfrombank");
	// 连接验证
	mgr->register_server_process(CMSG_PING, script_world_process_pong);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_PING, "script_world_process_pong");
	// 时间同步
	mgr->register_server_process(CMSG_QUERY_TIME, script_world_process_timequest);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_QUERY_TIME, "script_world_process_timequest");
	// 登录
	mgr->register_server_process(CMSG_LOGIN, script_world_process_authentication);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_LOGIN, "script_world_process_authentication");
	// 转发客户端数据
	mgr->register_server_process(CMSG_HANDLE_STRING, script_world_process_handlestringdata);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HANDLE_STRING, "script_world_process_handlestringdata");

	// 更新平台好友
	mgr->register_server_process(CMSG_CENTER_UPDATE_PLATFRIENDS, script_world_process_updateplatfriends);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_UPDATE_PLATFRIENDS, "script_world_process_updateplatfriends");
	// 好友列表
	mgr->register_server_process(CMSG_CENTER_FRIENDLIST_INFO, script_world_process_friendslist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_FRIENDLIST_INFO, "script_world_process_friendslist");
	// 好友信息
	mgr->register_server_process(CMSG_CENTER_FRIEND_INFO, script_world_process_friendinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_FRIEND_INFO, "script_world_process_friendinfo");
	// 好友操作
	mgr->register_server_process(CMSG_CENTER_OPERATOR_FRIEND, script_world_process_friendoperator);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_OPERATOR_FRIEND, "script_world_process_friendoperator");


	// 请求登陆服务器信息
	mgr->register_server_process(CMSG_REQUEST_LOGINSERVER, script_world_process_request_loginserver);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_REQUEST_LOGINSERVER, "script_world_process_request_loginserver");
	// 客户端资源加载完成
	mgr->register_server_process(CMSG_RESOURCELOADED, script_world_process_clientloadfinish);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_RESOURCELOADED, "script_world_process_clientloadfinish");
	// 使用自身道具
	mgr->register_server_process(CMSG_USETABLE_PORP, script_world_process_useprop);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_USETABLE_PORP, "script_world_process_useprop");
	// 验证乐码
	mgr->register_server_process(CMSG_CHECK_LECARD, script_world_process_checklecard);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHECK_LECARD, "script_world_process_checklecard");
	// 领取乐码
	mgr->register_server_process(CMSG_CHECK_GETLECARD, script_world_process_getlecard);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CHECK_GETLECARD, "script_world_process_getlecard");
	// 更新形象
	mgr->register_server_process(CMSG_UPDATE_BODY, script_world_process_updatebody);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_UPDATE_BODY, "script_world_process_updatebody");

	// 乐币换积分
	mgr->register_server_process(CMSG_GAME_LEBICHANGESCORE, script_world_process_lebichangescore);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GAME_LEBICHANGESCORE, "script_world_process_lebichangescore");
	// 积分换铜钱
	mgr->register_server_process(CMSG_GAME_SCORECHANGECOINS, script_world_process_scorechangecoins);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GAME_SCORECHANGECOINS, "script_world_process_scorechangecoins");
	// 特效包
	mgr->register_server_process(CMSG_SHARD_GRAPHIC, script_world_process_shardgraphics);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SHARD_GRAPHIC, "script_world_process_shardgraphics");
	// 表情包
	mgr->register_server_process(CMSG_BROW_GRAPHIC, script_world_process_flower);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_BROW_GRAPHIC, "script_world_process_flower");
	// 签到
	mgr->register_server_process(CMSG_SIGNIN_OPERATION, script_world_process_signin);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SIGNIN_OPERATION, "script_world_process_signin");
	// 兑换卡
	mgr->register_server_process(CMSG_EXCHANGE_CDKEY, script_world_process_cdkey);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_EXCHANGE_CDKEY, "script_world_process_cdkey");
	// 获取json任务格式的列表
	mgr->register_server_process(CMSG_JSON_MISSION_LIST, script_process_getcommon_jsonmissionlist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JSON_MISSION_LIST, "script_process_getcommon_jsonmissionlist");
	// 领取json任务格式的奖励
	mgr->register_server_process(CMSG_GET_JSON_MISSION_GETBOUNTY, script_process_getcommon_jsonmissionbounty);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GET_JSON_MISSION_GETBOUNTY, "script_process_getcommon_jsonmissionbounty");
	// 获取json成就格式的列表
	mgr->register_server_process(CMSG_JSON_EFFORT_LIST, script_process_getcommon_jsoneffectlist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JSON_EFFORT_LIST, "script_process_getcommon_jsoneffectlist");
	// 领取json成就格式的奖励
	mgr->register_server_process(CMSG_GET_JSON_EFFORT_GETBOUNTY, script_process_getcommon_jsoneffectbounty);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GET_JSON_EFFORT_GETBOUNTY, "script_process_getcommon_jsoneffectbounty");
	// 获取公共排行数据
	mgr->register_server_process(CMSG_COMMON_ORDERLIST, script_world_process_getcommonplayertop);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_COMMON_ORDERLIST, "script_world_process_getcommonplayertop");
	// 获取公共排行数据D7
	mgr->register_server_process(CMSG_COMMON_ORDERLISTNEW, script_world_process_getcommonplayertopnew);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_COMMON_ORDERLISTNEW, "script_world_process_getcommonplayertopnew");

	// 发送弹幕
	mgr->register_server_process(CMSG_DANMU, script_world_process_senddanmu);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_DANMU, "script_world_process_senddanmu");
	// 弹幕历史
	mgr->register_server_process(CMSG_DANMU_HISTORY, script_world_process_danmuhistory);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_DANMU_HISTORY, "script_world_process_danmuhistory");
	// 通过PID查询玩家信息
	mgr->register_server_process(CMSG_GETPLAYERINFO_BYPID, script_world_process_getplayerinfobypid);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETPLAYERINFO_BYPID, "script_world_process_getplayerinfobypid");

	///////////////////////////////// 开心牧场 ///////////////////////////////
	// 我的牧场
	mgr->register_server_process(CMSG_GETPRAIRIE_LIST, script_world_process_myfarm);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETPRAIRIE_LIST, "script_world_process_myfarm");
	// 买卖牲畜
	mgr->register_server_process(CMSG_HAPPYPRAIRIE_BUY, script_world_process_buyfarm);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HAPPYPRAIRIE_BUY, "script_world_process_buyfarm");
	// 赠送
	mgr->register_server_process(CMSG_GIVE_PRAIRIE, script_world_process_givingfarm);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GIVE_PRAIRIE, "script_world_process_givingfarm");
	// 赠送记录
	mgr->register_server_process(CMSG_GIVE_PRAIRIE_RECORD, script_world_process_givingrecode);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GIVE_PRAIRIE_RECORD, "script_world_process_givingrecode");
	// 赠送记录
	mgr->register_server_process(CMSG_BUYHAPPYFARM_LIST, script_world_process_buyfarmList);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_BUYHAPPYFARM_LIST, "script_world_process_buyfarmList");
	mgr->register_server_process(CMSG_SENDITEMTOUSER, script_world_process_givediamand);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SENDITEMTOUSER, "script_world_process_givediamand");
	mgr->register_server_process(CMSG_SENDRECVITEM_LOGS, script_world_process_giverecvitemlogs);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SENDRECVITEM_LOGS, "script_world_process_giverecvitemlogs");
	
	// CMSG_GETUSERCONTACT = 0x0064,		// 获取玩家联系信息
	mgr->register_server_process(CMSG_GETUSERCONTACT, script_world_process_getusercontact);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GETUSERCONTACT, "script_world_process_getusercontact");
	// CMSG_SETUSERCONTACT = 0x0065,		// 设置玩家联系信息
	mgr->register_server_process(CMSG_SETUSERCONTACT, script_world_process_setusercontact);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_SETUSERCONTACT, "script_world_process_setusercontact");
	
	///////////////////////////////// 红包相关 ///////////////////////////////
	// 发红包
	mgr->register_server_process(CMSG_HONGBAO_PROVIDE, script_world_process_awardhongbao);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_PROVIDE, "script_world_process_awardhongbao");
	// 抢红包
	mgr->register_server_process(CMSG_HONGBAO_KNOCK, script_world_process_grabhongbao);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_KNOCK, "script_world_process_grabhongbao");
	// 红包记录
	mgr->register_server_process(CMSG_HONGBAO_LIST, script_world_process_hongbaohistory);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_LIST, "script_world_process_thongbaohistory");
	// 请求发红包
	mgr->register_server_process(CMSG_HONGBAO_REQUEST, script_world_process_requesthongbao);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_REQUEST, "script_world_process_requesthongbao");
	// 抢红包详细列表
	mgr->register_server_process(CMSG_HONGBAO_KNOCKLIST, script_world_process_hongbaoknocklist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_KNOCKLIST, "script_world_process_thongbaoknocklist");
	// 排行榜
	mgr->register_server_process(CMSG_HONGBAO_TOPLIST, script_world_process_hongbaotoplist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_TOPLIST, "script_world_process_hongbaotoplist");
	// 可抢红包列表
	mgr->register_server_process(CMSG_HONGBAO_CANKNOCKLIST, script_world_process_hongbaocangrablist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_HONGBAO_CANKNOCKLIST, "script_world_process_hongbaocangrablist");
	// 中秋分享活动
	mgr->register_server_process(CMSG_ZHONGQIU_ACTIVITY, script_world_process_zhongqiu_activity);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_ZHONGQIU_ACTIVITY, "script_world_process_zhongqiu_activity");

	// 斗地主牌桌列表信息
	mgr->register_server_process(CMSG_DDZ_CHANNELLISTINFO, script_world_process_common_ddzchannellist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_DDZ_CHANNELLISTINFO, "script_world_process_common_ddzchannellist");


	mgr->register_server_process(CMSG_JUDGE_TOTALINFO, script_world_process_judge_totalinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JUDGE_TOTALINFO, "script_world_process_judge_totalinfo");
	mgr->register_server_process(CMSG_JUDGE_JUDGEPLAYER, script_world_process_judge_result);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JUDGE_JUDGEPLAYER, "script_world_process_judge_result");
	mgr->register_server_process(CMSG_JUDGE_INFOLIST, script_world_process_judge_list);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JUDGE_INFOLIST, "script_world_process_judge_list");
	mgr->register_server_process(CMSG_JUDGE_RESULTINFO, script_world_process_judge_resultlist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_JUDGE_RESULTINFO, "script_world_process_judge_resultlist");

	mgr->register_server_process(CMSG_CENTERBATTLE_AGREEORREFUSEPLAY, script_world_process_centerbattle_agreeorrefuseplayer);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_AGREEORREFUSEPLAY, "script_world_process_centerbattle_agreeorrefuseplayer");

	mgr->register_server_process(CMSG_CENTERBATTLE_CHOOSEPOS, script_world_process_centerbattle_playerchooseseat);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_CHOOSEPOS, "script_world_process_centerbattle_playerchooseseat");
	mgr->register_server_process(CMSG_CENTERBATTLE_SENDVOTE, script_world_process_centerbattle_playersendvote);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_SENDVOTE, "script_world_process_centerbattle_playersendvote");
	mgr->register_server_process(CMSG_CENTERBATTLE_VOTELIST, script_world_process_centerbattle_playerdealvote);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_VOTELIST, "script_world_process_centerbattle_playerdealvote");
	mgr->register_server_process(CMSG_GIVE_FREEGIFT, script_world_process_givefreegift);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GIVE_FREEGIFT, "script_world_process_givefreegift");
	mgr->register_server_process(CMSG_REQUIRE_JOINCENTERBATTLE, script_world_process_require_canjoincenterbattle);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_REQUIRE_JOINCENTERBATTLE, "script_world_process_require_canjoincenterbattle");
	mgr->register_server_process(CMSG_CENTERBATTLE_PUBLICLIST, script_world_process_require_centerbattlepubliclist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_PUBLICLIST, "script_world_process_require_centerbattlepubliclist");
	mgr->register_server_process(CMSG_CREATEORJOIN_CENTERBATTLE, script_world_process_createorjoin_centerbattle);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CREATEORJOIN_CENTERBATTLE, "script_world_process_createorjoin_centerbattle");
	mgr->register_server_process(CMSG_CENTER_GETDDZPUBLICBATTLELIST, script_world_process_ddz_publicbattlelist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_GETDDZPUBLICBATTLELIST, "script_world_process_ddz_publicbattlelist");
	mgr->register_server_process(CMSG_CENTER_LOCKDDZPUBLICBATTLE, script_world_process_ddz_publicbattlelock);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_LOCKDDZPUBLICBATTLE, "script_world_process_ddz_publicbattlelock");
	mgr->register_server_process(CMSG_CENTERBATTLE_PLAYERINFO, script_world_process_centerbattle_playerinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_PLAYERINFO, "script_world_process_centerbattle_playerinfo");
	mgr->register_server_process(CMSG_CENTERBATTLE_PLAYERSINGLELOGS, script_world_process_centerbattle_singlelogs);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTERBATTLE_PLAYERSINGLELOGS, "script_world_process_centerbattle_singlelogs");
	mgr->register_server_process(CMSG_COMMON_GETTOWNPLAYERCOUNT, script_world_process_common_requiretownplayercount);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_COMMON_GETTOWNPLAYERCOUNT, "script_world_process_common_requiretownplayercount");
	// CMSG_CENTERBATTLE_MATCHZONELOGS = 0x2023,		// 赛区战绩记录列表
	mgr->register_server_process(CMSG_CENTERBATTLE_MATCHZONELOGS, script_world_process_centerbattle_matchzonelogs);
	// 签到
	mgr->register_server_process(CMSG_COMMON_SIGN, script_world_process_common_sign);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_COMMON_SIGN, "script_world_process_common_sign");
	// 签名
	mgr->register_server_process(CMSG_COMMON_SIGNNAME, script_world_process_common_signname);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_COMMON_SIGNNAME, "script_world_process_common_signname");
	///////////////////////////////// 公共好友相关 ///////////////////////////////


	///////////////////////////////// 组局相关 ///////////////////////////////
	// 获取中心玩家数据0x0089
	mgr->register_server_process(CMSG_CENTER_PLAYERINFO, script_world_process_playeruserinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_PLAYERINFO, "script_world_process_playeruserinfo");
	// 获取用户组局统计信息0x008C
	mgr->register_server_process(CMSG_CENTER_PLAYERCOUNTINFO, script_world_process_playercountinfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_PLAYERCOUNTINFO, "script_world_process_playercountinfo");

	// 申请组局0x00F1
	mgr->register_server_process(CMSG_CENTER_BATLLE_REQUIRECREATE, script_world_process_require_createcenterbattle);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATLLE_REQUIRECREATE, "script_world_process_require_createcenterbattle");
	// 申请组局列表信息0x00F2
	mgr->register_server_process(CMSG_CENTER_BATTLE_LIST, script_world_process_centerbattle_list);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATTLE_LIST, "script_world_process_centerbattle_list");
	// 申请组局信息0x00F3
	mgr->register_server_process(CMSG_CENTER_BATTLE_INFO, script_world_process_centerbattle_info);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATTLE_INFO, "script_world_process_centerbattle_info");
	// 申请服务器创建牌桌0x00F4
	mgr->register_server_process(CMSG_GAME_BATTLE_CREATE, script_world_process_centerbattle_create_gamechannel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_GAME_BATTLE_CREATE, "script_world_process_centerbattle_create_gamechannel");
	// 牌局即时输赢0x00FB
	mgr->register_server_process(CMSG_CENTER_BATTLE_CURRWINLOSE, script_world_process_center_battle_currwinlose);
	Log.Debug("World Process", "Register opcode 0x%04x Process:[%s]", CMSG_CENTER_BATTLE_CURRWINLOSE, "script_world_process_center_battle_currwinlose");
	// 请求单局游戏输赢明细
	mgr->register_server_process(CMSG_CENTER_BATTLE_SINGLELOOPLOG, script_world_process_centerbattle_looplog);
	Log.Debug("World Process", "Register opcode 0x%04x Process:[%s]", CMSG_CENTER_BATTLE_SINGLELOOPLOG, "script_world_process_centerbattle_looplog");
	// 组局玩家行踪0x00FD
	mgr->register_server_process(CMSG_LASTZUJU_TRACKINFO, script_world_process_centerbattle_zujutrack);
	Log.Debug("World Process", "Register opcode 0x%04x Process:[%s]", CMSG_LASTZUJU_TRACKINFO, "script_world_process_centerbattle_zujutrack");
	// 游戏录像
	mgr->register_server_process(CMSG_GAMERECORD_VEDIO, script_world_process_gamerecord_vedio);
	Log.Debug("World Process", "Register opcode 0x%04x Process:[%s]", CMSG_GAMERECORD_VEDIO, "script_world_process_gamerecord_vedio");
	// 系统推荐好友
	mgr->register_server_process(CMSG_CENTER_SYSTEMFRIENDS, script_world_process_systemfriends);

	// 操作牌桌 0x00F6 
	mgr->register_server_process(CMSG_CENTER_BATTLE_OPERATOR, script_world_process_centerbattle_operatorchannel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATTLE_OPERATOR, "script_world_process_centerbattle_operatorchannel");
	// 踢人 0x00F7 
	// mgr->register_server_process(CMSG_CENTER_BATTLE_KICK,script_world_process_centerbattle_kickplayer);
	// Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]",CMSG_CENTER_BATTLE_KICK,"script_world_process_centerbattle_kickplayer");
	// 进入牌桌 0x00F8
	mgr->register_server_process(CMSG_CENTER_BATTLE_JOINCHANNEL, script_world_process_centerbattle_joinchannel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATTLE_JOINCHANNEL, "script_world_process_centerbattle_joinchannel");
	// 玩家组局记录 0x00F9
	mgr->register_server_process(CMSG_CENTER_PLAYER_BATTLELOG, script_world_process_centerbattle_playerlogs);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_PLAYER_BATTLELOG, "script_world_process_centerbattle_playerlogs");
	// 组局信息记录 0x00FA
	mgr->register_server_process(CMSG_CENTER_BATTLE_LOG, script_world_process_centerbattle_logs);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_BATTLE_LOG, "script_world_process_centerbattle_logs");
	//CMSG_CENTER_CHANGECENTERBATTLE = 0x2016 组局换桌
	mgr->register_server_process(CMSG_CENTER_CHANGECENTERBATTLE, script_world_process_changecenterbattle);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_CENTER_CHANGECENTERBATTLE, "script_world_process_changecenterbattle");
	// CMSG_COMMON_CONFIGMISSIONLIST = 0x2200, 	// 配置任务列表
	mgr->register_server_process(CMSG_COMMON_CONFIGMISSIONLIST, script_world_process_common_configmissionlist);
	// CMSG_COMMON_CONFIGMISSIONGET = 0x2201,	// 领取配置任务
	mgr->register_server_process(CMSG_COMMON_CONFIGMISSIONGET, script_world_process_common_configmissionget);
	// CMSG_COMMON_UPDATECONFIGMISSIONSTATUS = 0x2202,		// 任务状态更新
	mgr->register_server_process(CMSG_COMMON_UPDATECONFIGMISSIONSTATUS, script_world_process_common_configmissionstatusupdate);
	
	//============================================================================
	///////////////////////////////// 网关命令 ///////////////////////////////
	// 注册用户
	mgr->register_gateway_command(GameCommand_RegUser, script_process_world_game_command_register_user);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_RegUser, "script_process_world_game_command_register_user");
	// 修改用户信息
	mgr->register_gateway_command(GameCommand_ReUser, script_process_world_game_command_reuser);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_ReUser, "script_process_world_game_command_reuser");
	// 删除用户
	mgr->register_gateway_command(GameCommand_DelUser, script_process_world_game_command_deluser);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_DelUser, "script_process_world_game_command_deluser");
	// 充值
	mgr->register_gateway_command(GameCommand_UserBuy, script_process_world_game_command_userbuy);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_UserBuy, "script_process_world_game_command_userbuy");
	// 封号
	mgr->register_gateway_command(GameCommand_LockUser, script_process_world_game_command_lockuser);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_LockUser, "script_process_world_game_command_lockuser");
	// 取消封号
	mgr->register_gateway_command(GameCommand_UnLockUser, script_process_world_game_command_unlockuser);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_UnLockUser, "script_process_world_game_command_unlockuser");
	// 公告
	mgr->register_gateway_command(GameCommand_Notice, script_process_world_game_command_notice);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_Notice, "script_process_world_game_command_notice");
	// 添加物品
	mgr->register_gateway_command(GameCommand_AddItem, script_process_world_game_command_additem);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_AddItem, "script_process_world_game_command_additem");
	// 删除物品
	mgr->register_gateway_command(GameCommand_DeleteItem, script_process_world_game_command_deleteitem);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_DeleteItem, "script_process_world_game_command_deleteitem");
	// 双方猜拳次数不扣
	mgr->register_gateway_command(GameCommand_BothDisableMCount, script_process_world_game_command_setBothDisableMCount);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", GameCommand_BothDisableMCount, "script_process_world_game_command_setBothDisableMCount");

	// 重新加载物品脚本
	mgr->register_gateway_command(GameCommand_reloadscriptsItem, script_process_world_game_command_reloadscripts);
	mgr->register_gateway_command(GameCommand_RePwd2, script_process_world_game_command_repwd2);
	mgr->register_gateway_command(GameCommand_reloaditemmodel, script_process_world_game_command_reloaditemmodel);

	mgr->register_gateway_command(GameCommand_reloadmissionmodel, script_process_world_game_command_reloadmissionmodel);

	mgr->register_gateway_command(GameCommand_reloadtown, script_process_world_game_command_reloadtown);

	mgr->register_gateway_command(GameCommand_reloadgoods, script_process_world_game_command_reloadgoods);

	mgr->register_gateway_command(GameCommand_reloadgameconf, script_process_world_game_command_reloadgameconf);

	mgr->register_gateway_command(GameCommand_reloadeffects, script_process_world_game_command_reloadeffectmodel);
	// 添加邮件
	mgr->register_gateway_command(GameCommand_AddMail, script_process_world_game_command_addmail);
	// 添加兑换礼包
	mgr->register_gateway_command(GameCommand_addExchangeCards, script_process_world_game_command_addexchangecards);

	mgr->register_gateway_command(GameCommand_reloadMessage, script_process_world_game_command_reloadmessage);
	// 会员充值物品
	mgr->register_gateway_command(GameCommand_UserBuyItems, script_process_world_game_command_userbuyitems);
	mgr->register_gateway_command(GameCommand_removeChar, script_process_world_game_command_removeChar);

	mgr->register_gateway_command(GameCommand_reloadNotice, script_process_world_game_command_reloadNotice);

	mgr->register_gateway_command(GameCommand_reloadSMGameConf, script_process_world_game_command_reloadsmgameconf);

	mgr->register_gateway_command(GameCommand_CoalitionUser, script_process_world_game_command_coalitionuserdata);

	mgr->register_gateway_command(GameCommand_Shutup, script_process_world_game_command_nospeak);

	mgr->register_gateway_command(GameCommand_UnShutup, script_process_world_game_command_canspeak);

	mgr->register_gateway_command(GameCommand_reloadRoulette, script_process_world_game_command_reloadroulette);

	mgr->register_gateway_command(GameCommand_deleteChannel, script_process_world_game_command_deleteChannel);
	// 重新加载游戏分区名字配置文件
	mgr->register_gateway_command(GameCommand_reloadGzIdXml, script_process_world_game_command_reloadgzidconf);
	// 清理系统公告列表
	mgr->register_gateway_command(GameCommand_clearNotices, script_process_world_game_command_clearNotices);
	// 重新加载充值vip卡相关信息
	mgr->register_gateway_command(GameCommand_reloadVips, script_process_world_game_command_reloadVipCards);

	mgr->register_gateway_command(GameCommand_NoTrade, script_process_world_game_command_noTrade);

	mgr->register_gateway_command(GameCommand_CanTrade, script_process_world_game_command_canTrade);
	// 允许猜拳
	mgr->register_gateway_command(GameCommand_EnableMCount, script_process_world_game_command_enableMCount);
	// 禁止猜拳
	mgr->register_gateway_command(GameCommand_DisableMCount, script_process_world_game_command_disableMCount);
	// 添加猜拳次数
	mgr->register_gateway_command(GameCommand_AddMCount, script_process_world_game_command_addMCount);
	// 添加VIP勋章
	mgr->register_gateway_command(GameCommand_AddVip, script_process_world_game_command_addviphonor);
	// 删除VIP勋章
	mgr->register_gateway_command(GameCommand_RemoveVip, script_process_world_game_command_removeviphonor);
	// 用户角色交换
	mgr->register_gateway_command(GameCommand_ChangeUser, script_process_world_game_command_changeuser);
	// 手动替玩家取钱
	mgr->register_gateway_command(GameCommand_GetBank, script_process_world_game_command_getbankdata);
	// 恢复游戏跳转状态
	mgr->register_gateway_command(GameCommand_ResetExchange, script_process_world_game_command_resetbankstatus);
	// 重载serverdata.xml
	mgr->register_gateway_command(GameCommand_reloadSevIP, script_process_world_game_command_reloadgameinfo);
	// 重新加载分区配置
	mgr->register_gateway_command(GameCommand_reloadGZIds, script_process_world_game_command_reloadGZIds);
	// 重载组局开具费用配置
	mgr->register_gateway_command(GameCommand_ReloadCenterBattleOpenCoinsXml, script_process_world_game_command_reloadcenterbattleopencoinsxml);
	// 重载centerbattle_modeai.xml
	mgr->register_gateway_command(GameCommand_ReloadCenterBattleModeaiXml, script_process_world_game_command_reloadcenterbattlemodeai);
	// 添加银行存款
	mgr->register_gateway_command(GameCommand_additemforbank, script_process_world_game_command_additemforbank);
	// 减少银行存款
	mgr->register_gateway_command(GameCommand_reduceitemforbank, script_process_world_game_command_reduceitemforbank);
	// 重新加载金皇冠配置
	mgr->register_gateway_command(GameCommand_reloadGoldCoronal, script_process_world_game_command_reloadGoldCoronal);
	// 操作物品	
	mgr->register_gateway_command(GameCommand_operationitem, script_process_world_game_command_operationitem);
	// 重载IP伪真实地址
	mgr->register_gateway_command(GameCommand_reloadipsift, script_process_world_game_command_reloadipsift);
	// 重载VIP房间铜钱配置
	mgr->register_gateway_command(GameCommand_reloadVipRoomCoins, script_process_world_game_command_reloadviproomcoins);
	// 重载限时打折
	mgr->register_gateway_command(GameCommand_reloaddiscount, script_process_world_game_command_reloaddiscountxml);
	// 重载赠送乐码配置
	mgr->register_gateway_command(GameCommand_reloadRegGiveleCardsXml, script_process_world_game_command_reloadreggivelecardsxml);
	// 添加乐码
	mgr->register_gateway_command(GameCommand_reloadAddLeCards, script_process_world_game_command_addlecards);
	// 重载水果机配置
	mgr->register_gateway_command(GameCommand_reloadFruitXml, script_process_world_game_command_reloadfruitxml);
	// 重新加载物品集配置
	mgr->register_gateway_command(GameCommand_reloadItemSet, script_process_world_game_command_reloaditemset);
	// 重新加载过滤字符配置
	mgr->register_gateway_command(GameCommand_reloaddenywords, script_process_world_game_command_reloaddenywords);
	// 发送全服邮件
	mgr->register_gateway_command(GameCommand_addAllServerMail, script_process_world_game_command_addservermail);
	// 牧场动物操作
	mgr->register_gateway_command(GameCommand_farmOperator, script_process_world_game_command_operatorfarm);
	mgr->register_gateway_command(GameCommand_DebugSocket, script_process_world_game_command_debugSocketList);
	// 测试一些函数用的网关
	mgr->register_gateway_command(GameCommand_testSomeFunction, script_process_world_game_command_testsomefunc);
	// 重载buy_union_goods.xml
	mgr->register_gateway_command(GameCommand_ReloadBuyUnionGoodsXml, script_process_world_game_command_reloadbuyuniongoodsxml);
	// 操作月卡
	mgr->register_gateway_command(GameCommand_operationmonthcard, script_process_world_game_command_opmonthcardtimer);
	// 派乐盟兑换商品
	mgr->register_gateway_command(GameCommand_PaiLeMengExchange, script_process_world_game_command_pailemengexchange);
	// 封停俱乐部
	mgr->register_gateway_command(GameCommand_StopClub, script_process_world_game_command_stopclub);
	// 操作赛区信息
	mgr->register_gateway_command(GameCommand_OpMatchZone, script_process_world_game_command_opmatchzone);
	// 游戏作弊协议
	mgr->register_gateway_command(GameCommand_TestProtocols, script_process_world_game_command_testprotocols);
	// 重载my_gameids.xml配置
	mgr->register_gateway_command(GameCommand_ReloadMyGameIdsXml, script_process_world_game_command_reloadmygameidsxml);
	// 重载register_give_item配置
	mgr->register_gateway_command(GameCommand_ReloadRegisterGiveItemsXml, script_process_world_game_command_reloadregistergiveitemsxml);
	// 重载item_model_name配置
	mgr->register_gateway_command(GameCommand_ReloadItemModelNameXml, script_process_world_game_command_reloadItemModelNameXml);
	// 重载common_order.xml 配置
	mgr->register_gateway_command(GameCommand_ReloadCommonOrderXml, script_process_world_game_command_reloadCommonOrderXml);
	// 重载common_avtivity.xml 配置
	mgr->register_gateway_command(GameCommand_ReloadCommonAcvitityXml, script_process_world_game_command_reloadcommonactivityxml);
	// 重载common_sign.xml 配置
	mgr->register_gateway_command(GameCommand_ReloadCommonSignXml, script_process_world_game_command_reloadCommonSignXml);
	// 重载buile_common_efforts.xml 配置
	mgr->register_gateway_command(GameCommand_ReloadBuildCommonEffortXml, script_process_world_game_command_reloadBuildCommonEffortsXml);
	// 重载gateway_httphost.xml 配置
	mgr->register_gateway_command(GameCommand_ReloadGatewayHttphostXml, script_process_world_game_command_reloadGateWayHttpHostXml);

	///////////////////////////////// 服务器HOOK ///////////////////////////////
	// 服务器循环事件
	sScriptMgr.register_server_hook(SERVER_HOOK_LOOP, server_hook_loop);
	// 服务器启动事件
	sScriptMgr.register_server_hook(SERVER_HOOK_START, server_hook_start);
	// 服务器关闭连接事件
	sScriptMgr.register_server_hook(SERVER_HOOK_SLAVE_CLOSE, script_world_server_hook_slave_close);

	///////////////////////////////// 服务器指令 ///////////////////////////////
	mgr->register_server_command(1001, script_process_world_server_command_notice);

	// 注册网页调用网关
	mgr->register_httpd_request_handle(getway_http_handle);
}




